<template>
	<view>
		<view style="padding: 20upx;display: flex;flex-wrap: wrap;background-color: #fff;margin-top: 20upx;">
			<view style="margin-top: 30upx;display: flex;" v-for="(item,index) in list" :key='index' @click="openGame(item.bag,item.out_href)">
				<view>
					<image style="width: 150upx;height: 150upx;border-radius: 20upx;" :src="item.logo" mode=""></image>
				</view>
				<view style="margin-left: 20upx;margin-top: 10upx;">
					<view style="font-size: 34upx;">
						{{item.name}}
					</view>
					<view style="font-size: 22upx;">
						{{item.desc}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
			}
		},
		onLoad() {
			this.setajax()
		},
		methods: {
			setajax(){
				uni.request({
					url: 'http://mall.sytesco.com/gamelist.php',
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					method: 'POST',
					success: res => { 
						console.log(res)
						this.list = res.data.list
					},
					fail: () => {},
					complete: () => {},
				});
			},
			openGame(bag,out_href){
				console.log(bag,out_href)
				if(bag){
					console.log('打开游戏');
					plus.runtime.launchApplication(  
						{
							pname: bag  
						},   
						function(e) {
							console.log(e);
							if(e.code == -99){
								plus.runtime.openURL(out_href, function(res) {
									console.log('下载游戏');
								});  
							}
						}  
					);
					
				}
			},
		}
	}
</script>

<style>
	
</style>
